package com.onesports.intelligent.k12.polarlight.controller.operation;

import cn.gjing.excel.executor.ExcelFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.operation.FtbPageOrderDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.operation.FundsTradeBillPageVO;
import com.onesports.intelligent.k12.polarlight.service.order.FundsTradeBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @author chenrl
 **/
@Api(tags = "运营端-运营管理-充值订单")
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiPathConstants.FUNDS_TRADE_BILL)
public class fundsTradeBillController {

    private final FundsTradeBillService fundsTradeBillService;

    @ApiOperation("运营端-分页查询账单信息")
    @GetMapping("/select-page")
    public ResponseEntity<IPage<FundsTradeBillPageVO>> selectPage(@Valid FtbPageOrderDTO ftbPageOrderDTO) {
        return ResultUtil.success(fundsTradeBillService.selectPageAndTotal(new Page<FundsTradeBillPageVO>(ftbPageOrderDTO.getPage(),ftbPageOrderDTO.getRow()),ftbPageOrderDTO));
    }
    @ApiOperation("导出")
    @GetMapping("/export")
    public void export(HttpServletResponse response, FtbPageOrderDTO dto) {
        List<FundsTradeBillPageVO> fundsTradeBillPageVOS = fundsTradeBillService.selectExport(dto);
        ExcelFactory.createWriter(FundsTradeBillPageVO.class, response)
                .write(fundsTradeBillPageVOS).flush();
    }
}













